package org.keyyond.ms.commonservice.service.impl;

import java.util.List;

import org.keyyond.ms.commonservice.dao.SDBDRoleDao;
import org.keyyond.ms.commonservice.model.SDBDRole;
import org.keyyond.ms.commonservice.service.SDBDRoleService;
import org.keyyond.ms.core.util.Constant;
import org.keyyond.ms.core.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import net.sf.json.JSONObject;

@Service
public class SDBDRoleServiceImpl implements SDBDRoleService{
	
	@Autowired
	private SDBDRoleDao roleDao;

	@Override
	public List<SDBDRole> selectRolesByRoleIds(SDBDRole role) {
		// TODO Auto-generated method stub
		return roleDao.selectRolesByRoleIds(role);
	}

	@Override
	public List<SDBDRole> selectAll() {
		// TODO Auto-generated method stub
		return roleDao.selectAll();
	}

	@Override
	public int getAllFDFBRolesCount(SDBDRole role) {
		// TODO Auto-generated method stub
		return roleDao.getAllFDFBRolesCount(role);
	}

	@Override
	public Page<SDBDRole> selectAllByPage(JSONObject dataJson) {
		SDBDRole role = (SDBDRole) JsonUtil.jsonTBean(dataJson.getString("role"), SDBDRole.class);
		int startRows = dataJson.getInt(Constant.PAGE_STARTROW);
		int pageSizes = dataJson.getInt(Constant.PAGE_PAGESIZE);
		PageHelper.startPage(startRows, pageSizes);
		return roleDao.selectAllByPage(role);
	}

	@Override
	public int addFDFBRole(SDBDRole role) {
		// TODO Auto-generated method stub
		return roleDao.insert(role);
	}

	@Override
	public int deleteUserBySeqno(String seqno) {
		// TODO Auto-generated method stub
		return roleDao.deleteByPrimaryKey(seqno);
	}

	@Override
	public int updateRoleDynamic(SDBDRole role) {
		// TODO Auto-generated method stub
		return roleDao.updateRoleDynamic(role);
	}
	
}
